package cn.gemiman.daoyi.module.iot.dal.mysql.jhlequipmentdevice;

import cn.gemiman.daoyi.framework.common.pojo.PageResult;
import cn.gemiman.daoyi.framework.mybatis.core.mapper.BaseMapperX;
import cn.gemiman.daoyi.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.gemiman.daoyi.module.iot.controller.admin.jhlequipmentdevice.vo.JhlEquipmentDevicePageReqVO;
import cn.gemiman.daoyi.module.iot.dal.dataobject.jhlequipmentdevice.JhlEquipmentDeviceDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;

import java.io.Serializable;

/**
 * 精华隆设备信息 Mapper
 *
 * @author 道一源码
 */
@Mapper
public interface JhlEquipmentDeviceMapper extends BaseMapperX<JhlEquipmentDeviceDO> {

    @Delete("delete from iot_jhl_equipment_device where id = #{id}")
    void deleteAbsoluteById(Serializable id);

    default PageResult<JhlEquipmentDeviceDO> selectPage(JhlEquipmentDevicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<JhlEquipmentDeviceDO>()
                .eqIfPresent(JhlEquipmentDeviceDO::getArmStatus, reqVO.getArmStatus())
                .eqIfPresent(JhlEquipmentDeviceDO::getDeviceType, reqVO.getDeviceType())
                .inIfPresent(JhlEquipmentDeviceDO::getDeviceType, reqVO.getDeviceTypes())
                .eqIfPresent(JhlEquipmentDeviceDO::getDeviceIccid, reqVO.getDeviceIccid())
                .eqIfPresent(JhlEquipmentDeviceDO::getOnlineStatus, reqVO.getOnlineStatus())
                .eqIfPresent(JhlEquipmentDeviceDO::getPlaceId, reqVO.getPlaceId())
                .likeIfPresent(JhlEquipmentDeviceDO::getDeviceName, reqVO.getDeviceName())
                .eqIfPresent(JhlEquipmentDeviceDO::getParentId, reqVO.getParentId())
                .eqIfPresent(JhlEquipmentDeviceDO::getReportType, reqVO.getReportType())
                .eqIfPresent(JhlEquipmentDeviceDO::getMainCode, reqVO.getMainCode())
                .betweenIfPresent(JhlEquipmentDeviceDO::getLastOfflineTime, reqVO.getLastOfflineTime())
                .eqIfPresent(JhlEquipmentDeviceDO::getDeviceIdentifier, reqVO.getDeviceIdentifier())
                .eqIfPresent(JhlEquipmentDeviceDO::getMac, reqVO.getMac())
                .eqIfPresent(JhlEquipmentDeviceDO::getSubCode, reqVO.getSubCode())
                .betweenIfPresent(JhlEquipmentDeviceDO::getLastOnlineTime, reqVO.getLastOnlineTime())
                .betweenIfPresent(JhlEquipmentDeviceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(JhlEquipmentDeviceDO::getId));
    }

}
